package com.huashi.dealer.modular.controller.api.page.controller;

import com.huashi.dealer.core.pojo.CommonResult;
import com.huashi.dealer.modular.controller.api.page.service.PageService;
import com.huashi.dealer.modular.controller.api.page.param.PageResponseParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * API页面控制器
 *
 * @author 谭陈强
 * @since 2025-07-30
 */
@Tag(name = "API页面控制器")
@RestController("apiPageController")
@RequestMapping("/api/page")
@Validated
public class PageController {

    @Resource
    private PageService pageService;

    /**
     * 页面首页
     */
    @GetMapping("/index")
    @Operation(summary = "页面首页")
    public CommonResult<PageResponseParam> getPageIndex(@RequestParam(required = false) String token) {
        try {
            PageResponseParam responseParam = pageService.getPageIndex(token);
            return CommonResult.data(responseParam);
        } catch (Exception e) {
            return CommonResult.error("获取页面首页失败：" + e.getMessage());
        }
    }
} 